<template>
  <div class="contract-template-page">
    <div class="page-header">
      <h2>
        <el-icon><Document /></el-icon>
        合同模板管理
      </h2>
      <el-button type="primary" @click="handleCreate">
        <el-icon><Plus /></el-icon>
        新建模板
      </el-button>
    </div>

    <el-card>
      <el-row :gutter="20">
        <el-col :span="6" v-for="template in templates" :key="template.id">
          <el-card class="template-card" shadow="hover" @click="handleUseTemplate(template)">
            <div class="template-icon">
              <el-icon><Document /></el-icon>
            </div>
            <h3>{{ template.name }}</h3>
            <p>{{ template.description }}</p>
            <div class="template-footer">
              <span>使用次数：{{ template.usageCount }}</span>
              <el-button type="primary" size="small" text>使用模板</el-button>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { Document, Plus } from '@element-plus/icons-vue'

const templates = ref([
  { id: 1, name: '销售合同模板', description: '标准销售合同模板，包含常用条款', usageCount: 45 },
  { id: 2, name: '采购合同模板', description: '标准采购合同模板', usageCount: 38 },
  { id: 3, name: '服务合同模板', description: '服务类合同模板', usageCount: 52 },
  { id: 4, name: '租赁合同模板', description: '租赁合同模板', usageCount: 28 }
])

const handleCreate = () => {
  ElMessage.info('创建模板功能开发中')
}

const handleUseTemplate = (template) => {
  ElMessage.success(`使用模板：${template.name}`)
}
</script>

<style scoped>
.contract-template-page {
  padding: 20px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-header h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.template-card {
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
}

.template-card:hover {
  transform: translateY(-5px);
}

.template-icon {
  font-size: 48px;
  color: #409eff;
  margin-bottom: 15px;
}

.template-card h3 {
  margin: 0 0 10px 0;
  font-size: 16px;
}

.template-card p {
  margin: 0 0 15px 0;
  color: #909399;
  font-size: 14px;
}

.template-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid #f0f0f0;
  font-size: 12px;
  color: #909399;
}
</style>

